<?php
namespace app\controller\api;

use support\Request;
use Tinywan\Jwt\JwtToken;

class AuthController
{
    public function login(Request $request)
    {
        // 前端用户登录逻辑...
        $user = [
            'id' => 1,
            'name' => '测试用户'
        ];
        
        $jwt = JwtToken::getInstance();
        $token = $jwt->setPayload([
            'user_id' => $user['id'],
            'type' => 'user'  // 标识是前端用户
        ])->encode();
        
        return json([
            'code' => 0,
            'msg' => '登录成功',
            'data' => [
                'token' => $token,
                'user' => $user
            ]
        ]);
    }

    public function userInfo(Request $request)
    {
        return json([
            'code' => 0,
            'data' => $request->user
        ]);
    }
} 